package com.xd.core.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xd.core.system.entity.Dictionary;
import com.xd.core.system.mapper.DictionaryMapper;
import com.xd.core.system.service.IDictionaryService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 字典表 服务实现类
 * </p>
 *
 * @author SJ
 * @since 2023-03-24
 */
@Service

public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements IDictionaryService {


    @Override
    @Cacheable(value = "dict#15", key = "#type.toString()")
    public List<Dictionary> listByType(String type) {
        return this.baseMapper.listByType(type);
    }

    @Override
    @Cacheable(value = "company#15", key = "#type.toString()")
    public List<Dictionary> listByTypeCompany(String type) {
        return this.baseMapper.listByTypeCompany(type);
    }

    @Override
    @Cacheable(value = "dict#15", key = "#types.toString()")
    public List<Dictionary> listByTypes(List<String> types) {
        return this.baseMapper.listByTypes(types);
    }

    @Override
    @Cacheable(value = "dict#15", key = "#type.toString().concat(#codes.toString())")
    public List<Dictionary> listByTypeAndCodes(List<String> codes, String type) {
        return this.baseMapper.listByTypeAndCodes(codes, type);
    }

    @Override
    @CacheEvict(cacheNames = {"city", "dict", "dictionary"}, key = "'*'")
    public void flushed() {//刷新缓存
    }
}

